package com.myboot.controller;

import com.myboot.vo.UserVo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by liuhuan on 2017/1/10.
 */
@Controller
public class HelloController {

    @ResponseBody
    @RequestMapping("/hello")
    public String sayHello() {
        return "Hello World!";
    }

    @ResponseBody
    @RequestMapping("/getUserInfo")
    public UserVo getUserInfo() {
        UserVo vo = new UserVo();
        vo.setId(123);
        vo.setName("helloWorld");
        vo.setEmail("world@example.com");
        return vo;
    }

    @ResponseBody
    @RequestMapping("/getError")
    public String getErrorDemo() {
        int i = 100 / 0;
        return String.valueOf(i);
    }

    @RequestMapping("/index")
    public String index(Model model) {
        model.addAttribute("world", "Fuck Fuck Fuck!!!");
        return "/index";
    }

    @RequestMapping("/helloJsp")
    public String helloJsp(Model model){
        model.addAttribute("hello","123");
        return "hello";
    }


}
